from selenium.webdriver.common.by import By
from common.basepage import BasePage


class OrderPage(BasePage):

    """订单列表首页元素"""
    #  _locator = (By.XPATH, '')
    # 全部订单标签
    allOrders_label_locator = (By.XPATH, '//*[@class="page-title"]/li[contains(text(),"全部订单")]')
    # 待付款标签
    obligations_label_locator = (By.XPATH, '//*[@class="page-title"]/li[contains(text(),"待付款")]')
    # 待发货标签
    waitDeliver_label_locator = (By.XPATH, '//*[@class="page-title"]/li[contains(text(),"待发货")]')
    # 已发货标签
    delivered_label_locator = (By.XPATH, '//*[@class="page-title"]/li[contains(text(),"已发货")]')
    # 已完成标签
    completed_label_locator = (By.XPATH, '//*[@class="page-title"]/li[contains(text(),"已完成")]')
    # 已取消标签
    canceled_label_locator = (By.XPATH, '//*[@class="page-title"]/li[contains(text(),"已取消")]')
    # 已撤销标签
    undone_label_locator = (By.XPATH, '//*[@class="page-title"]/li[contains(text(),"已撤销")]')
    # 查询订单输入框
    order_input_locator = (By.XPATH, '//*[@placeholder="输入订单编号/顾客手机号"]')
    # 查询按钮
    search_btn_locator = (By.XPATH, '//*[@class="el-input__icon el-icon-search"]')
    # # 选择门店按钮
    # _locator = (By.XPATH, '//*[@placeholder="选择门店"]')
    # # 门店下拉选项
    # _locator = (By.XPATH, '//*[contains(@x-placement,"bottom")]//li')
    # # 下单时间按钮
    # _locator = (By.XPATH, '//*[@placeholder="选择下单时间"]')
    # # 下单时间下拉选项
    # _locator = (By.XPATH, '//*[contains(@x-placement,"bottom")]//li')
    # # 支付方式按钮
    # _locator = (By.XPATH, '//*[@placeholder="选择支付方式"]')
    # # 支付方式下拉选项
    # _locator = (By.XPATH, '//*[contains(@x-placement,"bottom")]//li')
    # # 订单来源按钮
    # _locator = (By.XPATH, '//*[@placeholder="选择订单来源"]')
    # # 订单来源下拉选项
    # _locator = (By.XPATH, '//*[contains(@x-placement,"bottom")]//li')
    # 付款按钮
    _locator = (By.XPATH, '')
    # 取消订单按钮
    _locator = (By.XPATH, '')
    # 查看订单
    _locator = (By.XPATH, '')
    # 列表订单状态-已取消，1已取消，2待付款，3已完成，4待发货，5已发货，6已撤销
    orderStatus_canceled_locator = (By.XPATH, '//*[@class="table-tr"][1]/div[8]/span[1]')
    # 列表订单状态-待付款
    orderStatus_obligations_locator = (By.XPATH, '//*[@class="table-tr"][1]/div[8]/span[2]')
    # 列表订单状态-已完成
    orderStatus_completed_locator = (By.XPATH, '//*[@class="table-tr"][1]/div[8]/span[3]')
    # 列表订单状态-待发货
    orderStatus_waitDeliver_locator = (By.XPATH, '//*[@class="table-tr"][1]/div[8]/span[4]')
    # 列表订单状态-已发货
    orderStatus_delivered_locator = (By.XPATH, '//*[@class="table-tr"][1]/div[8]/span[5]')
    # 列表订单状态-已撤销
    orderStatus_undone_locator = (By.XPATH, '//*[@class="table-tr"][1]/div[8]/span[6]')
    # 付款按钮
    payment_btn_locator = (By.XPATH, '//*[@class="table-tr"][1]/div[9]/span[text()="付款"]')
    # 取消订单按钮
    cancelOrder_btn_locator = (By.XPATH, '//*[@class="table-tr"][1]/div[9]/span[text()="取消订单"]')
    # 查看订单
    viewOrder_btn_locator = (By.XPATH, '//*[@class="table-tr"][1]/div[9]/span[text()="查看订单"]')
    # 取消订单弹窗-确认按钮
    cancelOrder_confirm_locator = (By.XPATH, '//*[@aria-label="提示"]//div/div[3]/button[2]')
    # 提示信息，通用
    prompt_msg_locator = (By.XPATH, '//*[@class="el-message__content"]')

    """待付款订单-查看订单页面元素"""
    # 关闭页面按钮
    closePage_btn_locator = (By.XPATH, '//*[@class="page-sub-title"]/div[1]/span[1]')
    # 去付款按钮
    goPayment_btn_locator = (By.XPATH, '//*[@class="page-sub-title"]/div[1]/span[2]')
    # 取消订单按钮
    view_cancelOrder_locator = (By.XPATH, '//*[@class="page-sub-title"]/div[1]/span[3]')
    # 备注订单按钮
    remarkOrder_btn_locator = (By.XPATH, '//*[@class="page-sub-title"]/div[1]/span[4]')

    # 取消订单按钮
    _locator = (By.XPATH, '')
    # 查看订单
    _locator = (By.XPATH, '')

    def search_order(self,order_num):
        """查询订单"""
        # 输入订单编号
        order_input = self.presence_only_wait(self.order_input_locator)
        order_input.clear()
        order_input.send_keys(order_num)
        # 点击查询按钮
        self.clickable_wait(self.search_btn_locator).click()

    def get_order_status(self):
        """获取列表订单状态"""
        return self.visible_only_wait(self.order_status_locator)


